
//选项菜单枚举
enum MeneOption
{
    Print_user,
    Alter_user,
    Find_book,
    Quit
};

int bookManager_menu()
{
    printf(" ========================================== \n");
    printf("              欢迎来到用户界面              \n");
    printf(" ****************************************** \n");
    printf("              1.查看个人信息                \n");
    printf("              2.修改个人信息                \n");
    printf("              3.查询图书                    \n");
    printf("              0.退出系统                    \n");
    printf(" ========================================== \n");
    printf("\n您好.请输入您的选择(1,2,3,4,5,6,7,8,9,0):\n");
    int op = -1;
    scanf("%d", &op);
    while (getchar() != '\n');
    return op;
}

//查询图书
void findBook() {
    char searchName[30];
    printf("请输入要查找的图书名称：");
    scanf("%s", searchName);

    for (int i = 0; i < num; i++) {
        if (strcmp(allBooks[i].name, searchName) == 0) {
            Bookimformationplus(allBooks[i]);
            // 返回用户界面
            int backToMenu;
            printf("输入任意键返回管理界面：");
            scanf("%d", &backToMenu);
            admin();
            return;
        }
    }
    center_printf("未找到该图书\n");

    //查看个人信息
    void viewUserInfo()
    {
        char studentID[11];
        printf("请输入您的学号以查看个人信息:\n");
        scanf("%s", studentID);

        struct student* studentInfo = readStudentInfo(studentID);
        if (studentInfo) {
            printf("\n个人信息:\n");
            printf("姓名: %s\n", studentInfo->student_name);
            printf("学号: %s\n", studentInfo->student_ID);
            printf("联系方式: %s\n", studentInfo->student_phone_number);
        }
        else {
            printf("未找到匹配的学生信息\n");
        }

        printf("\n3秒后将跳转至开始界面\n\n");
        sleep(3);
        showWelcomeScreen();
    }

    //修改个人信息
    void modifyUserInfo() {
        char studentID[11];
        printf("请输入您的学号以修改个人信息:\n");
        scanf("%s", studentID);

        struct student* studentInfo = readStudentInfo(studentID);
        if (!studentInfo) {
            printf("未找到匹配的学生信息\n");
            printf("\n3秒后将跳转至开始界面\n\n");
            sleep(3);
            showWelcomeScreen();
            return;
        }

        char newName[10], newPhoneNumber[12];
        
        printf("请输入新的姓名:\n");
        scanf("%s", newName);
        printf("请输入新的联系方式:\n");
        scanf("%s", newPhoneNumber);
     
        strcpy(studentInfo->student_name, newName);
        strcpy(studentInfo->student_phone_number, newPhoneNumber);

        printf("个人信息已修改\n");
        printf("\n3秒后将跳转至开始界面\n\n");
        sleep(3);
        showWelcomeScreen();
    }